<template>
	<view class="center">
		<view class="logo" @click="goLogin" :hover-class="!login ? 'logo-hover' : ''">
			<image class="logo-img" src="/static/user_icon.png"></image>
			<view class="logo-title">
				<view>
					<text v-if="user">Hi，{{user.nickName}}</text>
				</view>
				<view>
					<text v-if="user && user.power == 1" class="uer-name">系统管理员</text>
					<text v-if="user && user.power == 2" class="uer-name">监管人员</text>
					<text v-if="user && user.power == 3" class="uer-name">操作人员</text>
				</view>
				<view class="margin_top_l">
					<text v-if="user" style="font-size: 26rpx;">ID：{{user.no}}</text>
				</view>
			</view>
		</view>
		<view class="center-list">
			<view class="center-list-item u-border-bottom" @click="onAcsso">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20" name="setting"></u-icon></text>
				<text class="list-text">设置</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<view class="center-list-item u-border-bottom" v-if="!1 && user.power == 1" @click="goExamine">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20" name="setting"></u-icon></text>
				<text class="list-text">审批/申请</text>
				<u-badge max="99" :value="badgeVal" type="error"></u-badge>
				<text class="navigat-arrow">&#xe65e;</text>
				<!-- <u-badge :type="type" max="99" :value="value"></u-badge> -->
			</view>
			<view class="center-list-item u-border-bottom">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20" name="setting"></u-icon></text>
				<button open-type="share" class="custom-share-btn">邀请加入我的单位</button>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<view class="center-list-item u-border-bottom" v-if="user && (user.power == 1 || user.power == 2)" @click="onAdminNew">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20" name="list-dot"></u-icon></text>
				<text class="list-text">管理控制面板</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<view class="center-list-item u-border-bottom" v-if="user && (user.power == 1 || user.power == 2)" @click="onNote">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20" name="list-dot"></u-icon></text>
				<text class="list-text">管理通知</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
			<!-- <view class="center-list-item" @click="onMsg">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20"
						name="rewind-right"></u-icon></text>
				<text class="list-text">查看最近报警图片</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view> -->
		</view>
		<view class="center-list">
			<view class="center-list-item" @click="onService">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20" name="tags"></u-icon></text>
				<text class="list-text">服务条款及隐私</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
		</view>

		<!-- <view class="center-list">
			<view class="center-list-item" @click="onAbost">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20"
						name="file-text"></u-icon></text>
				<text class="list-text">关于应用</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
		</view>

		<view class="center-list">
			<view class="center-list-item" @click="toDealwith">
				<text class="list-icon" style="display: flex; align-items: center;"><u-icon color="#49a0ff" size="20"
						name="calendar"></u-icon></text>
				<text class="list-text">更新日志</text>
				<text class="navigat-arrow">&#xe65e;</text>
			</view>
		</view> -->
	</view>
</template>

<script>
	import { BASE_IP } from '@/common/http/url.js';
	export default {
		data() {
			return {
				login: false,
				avatarUrl: "/static/uni-center/logo.png",
				user: null,
				badgeVal: 99,
			}
		},
		onShareAppMessage() {
			return {
				title: this.user.nickName + '邀请您加入他的单位！',
				path: '/pagesMine/wxLogin/wxLogin?power=3&unitId=' + this.user.unitId,
				imageUrl: 'https://mp-bfea0f33-0deb-44c8-86f2-196dd6ca37a5.cdn.bspapp.com/test/head.jpg',
				success(res) {
					console.log('分享成功', res);
				},
				fail(err) {
					console.log('分享失败', err);
				}
			}
		},
		methods: {
			goLogin() {
				if (!this.login) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
				}
			},
			onAcsso() {
				uni.navigateTo({
					url: "/pagesMine/settting/settings"
				})
			},
			goExamine() {
				uni.navigateTo({
					url: "/pagesMine/examine/examine"
				})
			},
			onMsg() {
				let msgs = uni.getStorageSync("msgs")
				if (msgs == "" || msgs == undefined) {
					uni.navigateTo({
						url: "/pagesMine/notificationCenter/notice/notice"
					})
					return
				}
				let msg = msgs[0]

				if (!msg.isRead) {
					msg.isRead = true
					msgs[0] = msg
					uni.setStorageSync("msgs", msgs)
				}

				uni.navigateTo({
					url: '/pagesMine/notificationCenter/messageCenter/messageCenter?content=' + msg.content +
						'&time=' + msg.time + '&imgUrl=' + msg.imgUrl + "&position=" + msg.position
				});


				console.log(msgs)
			},
			onAdmin() {
				uni.navigateTo({
					url: "/pagesMine/admin/admin"
				})
			},
			onAdminNew() {
				uni.navigateTo({
					url: "/pagesMine/admin/newAdmin"
				})
			},
			onNote() {
				uni.navigateTo({
					url: "/pagesMine/admin/note"
				})
			},
			onHelp() {
				uni.showToast({
					title: "暂未开发",
					icon: "error"
				})
			},
			onService() {
				uni.navigateTo({
					url: "/pagesMine/termsService/termsService"
				})
			},
			onAbost() {
				uni.navigateTo({
					url: "/pagesMine/aboutme/aboutme"
				})
			},
			toDealwith() {
				// let url = "https://tools.kalvinbg.cn/convenience/seal"
				// plus.runtime.openURL(url, function(res) {
				// 	console.log(res);
				// });
				uni.navigateTo({
					url: "/pagesMine/container/container"
				})
			}

		},
		onShow() {
			let user = uni.getStorageSync("user")
			console.log(user)
			this.user = user
			if (user != "") {
				this.login = true
				this.user = user
			}
		}
	}
</script>

<style>
	@font-face {
		font-family: texticons;
		font-weight: normal;
		font-style: normal;
		src: url('https://at.alicdn.com/t/font_984210_5cs13ndgqsn.ttf') format('truetype');
	}

	page,
	view {
		display: flex;
	}

	page {
		background-color: #f8f8f8;
	}

	button::after {
		border: none;
	}

	.custom-share-btn {
		background: none;
		border: none;
		padding: 0;
		margin: 0;
		line-height: inherit;
		display: inline;
		color: inherit;
		font-size: inherit;
		color: #555;
		display: flex;
		align-items: center;
		width: 90vw;
	}

	.center {
		flex-direction: column;
	}

	.logo {
		width: 750upx;
		height: 240upx;
		padding: 20upx;
		box-sizing: border-box;
		color: black;
		flex-direction: row;
		align-items: center;
	}

	.logo-hover {
		opacity: 0.8;
	}

	.logo-img {
		width: 150upx;
		height: 150upx;
		border-radius: 150upx;
	}

	.logo-title {
		display: flex;
		flex-direction: column;
		margin-left: 20upx;
	}

	.uer-name {
		background: #49A0FF;
		color: #fff;
		margin-top: 20rpx;
		border-radius: 8rpx;
		padding: 4rpx 14rpx;
	}

	.go-login.navigat-arrow {
		font-size: 38upx;
		color: black;
	}

	.login-title {
		height: 150upx;
		align-items: self-start;
		justify-content: center;
		flex-direction: column;
		margin-left: 20upx;
	}

	.center-list {
		background-color: #FFFFFF;
		margin-top: 20upx;
		width: 750upx;
		flex-direction: column;
	}

	.center-list-item {
		height: 90upx;
		width: 750upx;
		box-sizing: border-box;
		flex-direction: row;
		padding: 0upx 20upx;
		display: flex;
		align-items: center;
	}

	.border-bottom {
		border-bottom-width: 1upx;
		border-color: #c8c7cc;
		border-bottom-style: solid;
	}

	.list-icon {
		width: 40upx;
		height: 90upx;
		line-height: 90upx;
		font-size: 34upx;
		color: #49A0FF;
		text-align: center;
		font-family: texticons;
		margin-right: 20upx;
	}

	.list-text {
		height: 90upx;
		line-height: 90upx;
		font-size: 34upx;
		color: #555;
		flex: 1;
		text-align: left;
	}

	.navigat-arrow {
		height: 90upx;
		width: 40upx;
		line-height: 90upx;
		font-size: 34upx;
		color: #555;
		text-align: right;
		font-family: texticons;
	}
</style>